import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { MaterialSupplierRelVO, MaterialSupplierRelForm, MaterialSupplierRelQuery } from '@/api/material/materialSupplierRel/types';

/**
 * 查询物料编码和供应商映射列表
 * @param query
 * @returns {*}
 */

export const listMaterialSupplierRel = (query?: MaterialSupplierRelQuery): AxiosPromise<MaterialSupplierRelVO[]> => {
  return request({
    url: '/material/materialSupplierRel/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询物料编码和供应商映射详细
 * @param id
 */
export const getMaterialSupplierRel = (id: string | number): AxiosPromise<MaterialSupplierRelVO> => {
  return request({
    url: '/material/materialSupplierRel/' + id,
    method: 'get'
  });
};

/**
 * 新增物料编码和供应商映射
 * @param data
 */
export const addMaterialSupplierRel = (data: MaterialSupplierRelForm) => {
  return request({
    url: '/material/materialSupplierRel',
    method: 'post',
    data: data
  });
};

/**
 * 修改物料编码和供应商映射
 * @param data
 */
export const updateMaterialSupplierRel = (data: MaterialSupplierRelForm) => {
  return request({
    url: '/material/materialSupplierRel',
    method: 'put',
    data: data
  });
};

/**
 * 删除物料编码和供应商映射
 * @param id
 */
export const delMaterialSupplierRel = (id: string | number | Array<string | number>) => {
  return request({
    url: '/material/materialSupplierRel/' + id,
    method: 'delete'
  });
};
